<?php

namespace App\Models\Wanggui;

use App\Models\BaseModel;
use App\Models\Traits\KfUid;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class BusinessAoiModel extends BaseModel
{
    use HasFactory, KfUid;

    protected $table = 'business_aoi';

    protected $fillable = [
        'name',
        'province',
        'city',
        'district',
        'cityCode',
        'level',
        'lng',
        'lat',
        'fullSpell',
        'dataId',
        'housePrice',
        'boundary',
        'createdAt',
        'updatedAt',
        'preOccupyUsername',
        'preOccupyMobile',
        'occupyStatus',
        'capacity',
        'population',
        'worth',
        'cityWorth',
    ];

    protected $appends = [
        'occupyStatusText'
    ];


    const OCCUPY_ON  = 1;
    const OCCUPY_OFF = 0;

    const OCCUPY_MAPPING = [
        self::OCCUPY_ON  => '已占用',
        self::OCCUPY_OFF => '未占用',
    ];

    const CAPACITY_ZERO_TO_THREE = 1;
    const CAPACITY_THREE_TO_FIVE = 2;
    const CAPACITY_SIX_TO_TEN    = 3;
    const CAPACITY_TEN_THEN_MORE = 4;

    const CAPACITY_MAPPING = [
        self::CAPACITY_ZERO_TO_THREE => '3以下',
        self::CAPACITY_THREE_TO_FIVE => '3-5',
        self::CAPACITY_SIX_TO_TEN    => '6-10',
        self::CAPACITY_TEN_THEN_MORE => '10以上',
    ];


    /**
     * 获得占用状态
     * @return string
     */
    public function getOccupyStatusTextAttribute(): string
    {
        return self::OCCUPY_MAPPING[$this->getAttribute('occupyStatus')] ?? '';
    }


}
